<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderItemsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 订单， 用户， 产品，多个产品 ，， 多对多多态关联；
        Schema::create('order_items', function (Blueprint $table) {
            $table->bigIncrements('id');

            $table->integer('order_id')->comment('订单id');
            $table->integer('user_id')->comment('订单id');
            $table->integer('order_number')->nullable()->comment('订单号');
            $table->integer('itemable_type')->nullable()->comment('curse,goods,vip,active 产品类型');
            $table->integer('itemable_id')->nullable()->comment('对应的商品id');
            $table->integer('coupon_id')->nullable()->comment('优惠卷id');
            $table->decimal('coupon_money',8,2)->nullable()->comment('优惠金额');
            $table->integer('user_coupon_id')->nullable()->comment('用户优惠券id');
            $table->decimal('item_money',8,2)->nullable()->comment('商品价格');
            $table->decimal('item_pay_money',8,2)->nullable()->comment('商品需支付金额--优惠后的金额');
            $table->timestamps();

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_items');
    }
}
